package adapter;

import java.util.ArrayList;

import com.adgroup.smartnote.R;
import com.androidquery.AQuery;

import JsonModel.FamiliarFriend;
import adapter.AdapterCategories.Holder;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterFamiliarFriend {
	ArrayList<FamiliarFriend> arr;
	Context c;
	public AdapterFamiliarFriend(Context c, ArrayList<FamiliarFriend> arr)
	{
		this.c = c;
		this.arr = arr;
	}
	public class Holder
	{
		ImageView iv;
		TextView tv;
	}
	public class Adapter extends BaseAdapter
	{

		@Override
		public int getCount() {
			return arr.size();
		}

		@Override
		public Object getItem(int arg0) {
			return arr.get(arg0);
		}

		@Override
		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		@Override
		public View getView(int arg0, View arg1, ViewGroup arg2) {
			Holder holder;
			LayoutInflater inflater = ((Activity) c).getLayoutInflater();
			if (arg1 == null) {
				holder = new Holder();
				arg1 = inflater.inflate(R.layout.itemfamiliargal, null);
				holder.tv = (TextView) arg1
						.findViewById(R.id.textViewNicknameResembleGal);
				holder.iv = (ImageView) arg1
						.findViewById(R.id.imageViewLogoResembleGal);				
				arg1.setTag(holder);
			} else {
				holder = (Holder) arg1.getTag();
			}
			holder.tv.setText(arr.get(arg0).getNickName());
			AQuery aq = new AQuery(arg1);
			Bitmap placeholder = aq.getCachedImage(R.drawable.imageload);
			aq.id(holder.iv).image(arr.get(arg0).getLink(), true,
						true, 0, 0, placeholder, AQuery.FADE_IN_NETWORK, 1.0f);
			return arg1; 
		}
		
	}
}
